package com.mch.main.common;

import java.io.InputStream;
import java.util.Properties;

import javax.swing.JFrame;

import org.mch.comm.exec.MsgException;
import org.mch.frame.itf.IMFrame;

public class MEnv {

	public static JFrame MAINFRAME;

	private static final Properties conf;
	static {
		InputStream is = MLoader.getResourceAsStream("resource/config/mchutils.properties");

		conf = new Properties();
		try {
			conf.load(is);
		} catch (Exception e) {
			throw new MsgException("加载 系统配置文件 mchutils.properties失败！");
		}
	}

	public static String get(String key) {
		return conf.getProperty(key);
	}

	public static boolean isDev() {
		String mchdev = conf.getProperty("mchdev");

		if (mchdev.equalsIgnoreCase("y") || mchdev.equalsIgnoreCase("yes") || mchdev.equalsIgnoreCase("true")) {
			return true;
		} else {
			return false;
		}
	}

	public static void setStatusMsg(String msg) {
		((IMFrame) MAINFRAME).setMsg(msg);
	}
}
